<template>
  <MainLayout 
    :role-name="'质量经理'"
    :system-title="'质量管理系统'"
    :base-route-path="loginInfo.redirectUrl"
    :user-name="userInfo.name"
  >
    <template #menu-items>
      <el-menu-item index="/quality-manager/dashboard">
        <el-icon><DataAnalysis /></el-icon>
        <span>质量数据看板</span>
      </el-menu-item>
      <el-menu-item index="/quality-manager/audit">
        <el-icon><Document /></el-icon>
        <span>质量审核管理</span>
      </el-menu-item>
      <el-menu-item index="/quality-manager/exception-tracking">
        <el-icon><Warning /></el-icon>
        <span>异常处理追踪</span>
      </el-menu-item>
    </template>
  </MainLayout>
</template>

<script setup lang="ts">
import MainLayout from '@/components/layout/MainLayout.vue'
import { DataAnalysis, Document, Warning } from '@element-plus/icons-vue'
import { userInfoStore } from '@/stores/userInfo';
import { loginInfoStore } from '@/stores/loginInfo';
import { getUserInfoService } from '@/api/UsersApi';
import { ElMessage } from 'element-plus';

const userInfo = userInfoStore();
const loginInfo = loginInfoStore();

const getUserInfo = async () => {
  try {
    let result = await getUserInfoService();
    //将用户信息保存到仓库中
    userInfo.setUserInfo(result.data);
  } catch (error) {
    ElMessage.error('获取用户信息失败');
  }
}

//当打开页面时获取当前用户基本信息
getUserInfo();
</script>

<style lang="scss" scoped>
// 这里可以添加质量经理特有的样式
</style>